﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BLL;


namespace Web.Shalo.BanPMS1.Admin
{
    public partial class DDDDaGiao : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["manv"] == null || Session["matkhau"] == null)
            {
                Response.Redirect("Default.aspx");
            }
            else
            {
                if (!IsPostBack)
                {
                    HienThiDDDaGiao();
                    MultiView1.ActiveViewIndex = 0;
                }
            }
        }
        public void HienThiDDDaGiao()
        {
            HoaDonController obj=new HoaDonController();
            GVDDHang.DataSource = obj.bllHienThiDDDaGiao();
            GVDDHang.DataBind();
        }

        protected void GVDDHang_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            int sohd = Convert.ToInt32(GVDDHang.Rows[e.NewSelectedIndex].Cells[0].Text);
            MultiView1.ActiveViewIndex = 1;
            HienThiTT(sohd);
        }

        public void HienThiTT(int sohd)
        {
            HoaDonController obj = new HoaDonController();
            DataTable tt = obj.bllHienTTDDDaGiao(sohd);
            labSohd.Text = tt.Rows[0]["SoHD"].ToString();
            labNgaylap.Text = tt.Rows[0]["Ngaylap"].ToString();
            labTenKH.Text=tt.Rows[0]["TenKH"].ToString();
            labNgaySinh.Text = tt.Rows[0]["NgaySinh"].ToString();
            labDiaChi.Text=tt.Rows[0]["DiaChi"].ToString();
            labSoDT.Text=tt.Rows[0]["SoDT"].ToString();
            labNVGiaoHang.Text = tt.Rows[0]["TenNV"].ToString();
            labNgayGiao.Text=tt.Rows[0]["NgayGiao"].ToString();
            labGhiChu.Text=tt.Rows[0]["GhiChu"].ToString();
            labTongTien.Text = tt.Rows[0]["TongTien"].ToString();

            CTHDController objcthd = new CTHDController();
            GVCthd.DataSource = objcthd.bllHienThiMHDaGiao(sohd);
            GVCthd.DataBind();
        }

        protected void btnDSDonDH_Click(object sender, EventArgs e)
        {
            Response.Redirect("DDDDaGiao.aspx");
        }

        protected void GVDDHang_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GVDDHang.PageIndex = e.NewPageIndex;
            HienThiDDDaGiao();
        }
    }
}